package com.springcloud.tread.config;

import cn.hutool.core.collection.CollUtil;
import com.springcloud.tread.pojo.IndexData;
import com.springcloud.tread.service.IndexDataClientService;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

//客户端降级处理
@Component
public class IndexDataClientHystrix implements FallbackFactory {

    @Override
    public IndexDataClientService create(Throwable cause) {
       return new IndexDataClientService() {
           @Override
           public List<IndexData> getIndexData(String id) {
               IndexData indexData = new IndexData();
               indexData.setDate("无信息！！");
               indexData.setClosePoint(0);
               return CollUtil.toList(indexData);
           }
       };
    }
}
